home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amoszine PD Edition 0
/
Amoszine PD Edition 0.adf
/
SOURCE_CODE
/
joy_text.AMOS
/
joy_text.amosSourceCode
< prev
next >
Wrap
AMOS Source Code
|
1993-02-25
|
3KB
|
123 lines
Rem ****************************************
Rem *** Entering text using the ***
Rem *** JOYSTICK ***
Rem *** By Graham Lund ***
Rem ****************************************
'
Screen Open 0,320,256,4,Lowres
Curs Off : Flash Off : Hide
Palette 0,$FFF,$11F,$FF0
Paper 0 : Cls
'
Rem Set up a string to hold the letters to be used
'
LETTR$="ABCDEFGHIJKLMNOPQRSTUVWXYZ., "
'
Rem Draw and grab a bob to be used to highlight chosen letter
'
Ink 3,0
Box 0,0 To 23,10
Get Bob 1,0,0 To 24,11
Cls 0
'
Rem Enter programmes title and explain how to choose a letter
'
Pen 3
Locate 0,4 : Centre "ENTERING TEXT USING JOYSTICK"
Pen 2
Locate 0,25 : Centre "Highlight letter by moving joystick."
Locate 0,27 : Centre "Press FIRE to select letter."
'
Rem Place the letters on the screen
'
Pen 1
Locate 4,17 : Print "A B C D E F G H I J"
Locate 4,19 : Print "K L M N O P Q R S T"
Locate 4,21 : Print "U V W X Y Z . , end"
'
Rem Draw a box to hold the name
'
Locate 0,8 : Centre "Name Box."
Ink 2 : Box 100,74 To 200,92
Ink 3 : Box 99,73 To 201,93
Ink 2 : Box 98,72 To 202,94
'
Proc _ENTERNAME
End
'
Procedure _ENTERNAME
Rem List the shared variables
'
Shared N$
Shared UP,LFT,DWN,RGHT,BX,BY,W,NAMEEND
'
Rem Enter initial values for the shared variables
'
UP=1 : LFT=1 : DWN=0 : RGHT=0 : W=1 : NAMEEND=0
BX=24 : BY=134
NAME$=""
LETTER=0
'
Rem Place the bob grabbed above around the first letter
'
Bob 1,BX,BY,1
Pen 3
'
Rem This part calls the procedure _PICKLETTER repeatedly until
Rem seven letters have been chosen at which point the repeat
Rem until loop is completed. The letters are entered into the
Rem string NAME$ by adding the string N$ to it each time a
Rem letter has been chosen and the string is displayed.
'
Repeat
Proc _PICKLETTER
NAME$=NAME$+N$
Locate 15,10 : Print NAME$
Inc LETTER
If NAMEEND=1 Then LETTER=7
Until LETTER=7
End Proc
'
Procedure _PICKLETTER
Shared N$,LETTR$
Shared UP,LFT,DWN,RGHT,BX,BY,W,NAMEEND
'
Rem This Repeat - Until loop reads the joystick and will only
Rem move the bob if the move is allowed by the values held in
Rem UP DWN LFT and RGHT
'
Q=0 : N$=""
Repeat
If LFT=0 and Jleft(1)
BX=BX-24 : RGHT=0 : Dec W
Else If RGHT=0 and Jright(1)
Add BX,24 : LFT=0 : Inc W
Else If UP=0 and Jup(1)
BY=BY-16 : DWN=0 : W=W-10
Else If DWN=0 and Jdown(1)
Add BY,16 : UP=0 : Add W,10
End If
End If
End If
End If
Bob 1,BX,BY,1
Wait 10
If BX=24 Then LFT=1
If BX=240 Then RGHT=1
If BY=134 Then UP=1
If BY=166 Then DWN=1
If Fire(1) Then Bell 70 : Q=1
Until Q=1
'
Rem A value of 30 for W means no more letters are needed
Rem so the NAMEEND variable is incremented
'
If W=30 Then NAMEEND=1 : N$=""
'
Rem The correct letter is retrieved from the LETTR$ string and
Rem fed into the N$ string
'
If W<30
N$=Mid$(LETTR$,W,1)
End If
End Proc